import { BasicColumn, FormSchema } from '@/components/Table';
import { h, ref } from 'vue';
import { Tag } from 'ant-design-vue';
import { ywUserSelectList } from '@/api/heng/ywManage';
import { ApiSelect } from '@/components/Form';
import util from '@/utils/util';

import { useMessage } from '@/hooks/web/useMessage';
import Ainput from '@/views/bookManage/components/account/Ainput.vue';
import { VxeFormItemProps, VxeGridPropTypes } from '@/components/VxeTable';
import { changeEnd } from 'codemirror';
import { style } from '@logicflow/extension/es/bpmn-elements/presets/icons';

type CheckedType = boolean | string | number;
// BasicColumn[]

// VxeColumnPropTypes.CellRender

/**
 */
export const vxeTableColumns: VxeGridPropTypes.Columns = [
  {
    title: 'ms物料编号',
    field: 'mtid',
    showOverflow: 'title',
    // filters: [{ data: '' }],
    // filterRender: {
    //   name: 'VxeInput',
    // },
  },

  {
    title: '迪卡侬物料编号',
    field: 'itemCode',
    showOverflow: 'title',
    align: 'center',
    width: 140,
  },

  {
    title: '迪卡侬物料名称',
    field: 'itemName',
    align: 'center',
    width: 150,
  },

  {
    title: '物料类型',
    field: 'type',
    align: 'center',
    formatter: ({ cellValue, row, column }) => {
      let val = '';
      if (!cellValue) {
        return val;
      }
      switch (cellValue) {
        case 'component':
          val = '配件';
          break;
        case 'carelabel':
          val = '防盗贴纸';
          break;
        default:
          break;
      }
      return val;
    },
    width: 100,
  },
  {
    title: '供应商编号',
    field: 'supplierCode',
    showOverflow: 'title',
    align: 'center',
    width: 140,
  },

  {
    title: '供应商名称',
    field: 'supplierName',
    align: 'center',
  },

  {
    title: 'code_cc',
    field: 'codeCc',
    align: 'center',
    width: 120,
  },
  {
    title: 'incoterm',
    field: 'incoterm',
    showOverflow: 'title',
    align: 'center',
    width: 140,
  },

  {
    title: 'DSM',
    field: 'dsmCode',
    align: 'center',
    width: 120,
  },
  {
    title: '创建时间',
    field: 'createTime',
    align: 'center',
    width: 150,
  },
  {
    width: 230,
    title: '操作',
    align: 'center',
    field: '',
    slots: { default: 'action' },
    fixed: 'right',
  },
];

export const vxeTableFormSchema: VxeFormItemProps[] = [
  {
    span: 5,
    field: 'keyword',
    title: '查询',
    itemRender: {
      props: {
        placeholder: 'ms编号，迪卡侬物料编号和名称',
      },
      name: 'AInput',
    },
  },
  {
    span: 5,
    field: 'type',
    title: '类型',
    itemRender: {
      name: 'ASelect',
      props: {
        style: { width: '100%' },
        options: [
          { label: '配件', value: 'component' },
          { label: '防盗贴纸', value: 'carelabel' },
        ],
      },
    },
  },
  {
    span: 5,
    itemRender: {
      name: 'VxeButtonGroup',
      options: [
        { type: 'reset', content: '重置' },
        { type: 'submit', content: '查询', status: 'primary' },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'mtid',
    label: 'ms物料编号',
    component: 'Input',
    required: true,
  },
  {
    field: 'itemCode',
    label: '迪卡侬物料编号',
    component: 'Input',
    required: true,
  },
  {
    field: 'itemName',
    label: '迪卡侬物料名称',
    component: 'Input',
    required: false,
  },
  {
    field: 'type',
    label: '类型',
    component: 'Select',
    required: true,
    // defaultValue: '1',
    componentProps: {
      options: [
        { label: '配件', value: 'component' },
        { label: '防盗贴纸', value: 'carelabel' },
      ],
    },
    colProps: { lg: 24, md: 24 },
  },
  {
    field: 'supplierName',
    label: '供应商名称',
    component: 'Input',
  },

  {
    field: 'supplierCode',
    label: '供应商编号',
    component: 'Input',
  },
  {
    field: 'code_cc',
    label: 'codeCc',
    component: 'Input',
  },
  {
    field: 'dsm',
    label: 'dsmCode',
    component: 'Input',
  },
  // {
  //   field: 'DPP名称',
  //   label: 'dppName',
  //   component: 'Input',
  // },

  // {
  //   field: 'DPP编号',
  //   label: 'dppCode',
  //   component: 'Input',
  // },
];
